<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/jsp/include/taglib.jsp"%>
<%@ include file="/jsp/include/headlist.jsp"%>
<html>
<head>
	<title>长编管理</title>

<META http-equiv="x-ua-compatible" content="IE=8">

	<script type="text/javascript">
		var refreshFlag = false;
		$(document).ready(function() {
			$("#searchForm").validate();
			
			$("#btnSubmit").click(function(){
				$("#searchForm").submit();
			});				
			$("#resetBut").click(function(){
				$(".ul-form input:text").not('.readonly').val("");
				$(".ul-form select").val("");
			});	
			
			$("[name=checkAll]").click(function(){
				if($(this).attr("checked") == "checked"){
					$("[name=summaryCheckbox]").attr("checked",true);
				}else{
					$("[name=summaryCheckbox]").attr("checked",false);
				}
		    });   			
			
			window.onfocus = function(){
				if(refreshFlag){
					refreshFlag = false;
					$("#searchForm").submit();
				}
		  	};
		  	
		  	
		  	
		  	$('#export').click(function(){
		  		
		  		var ids="";
		  		var selectedCards = $('[name=summaryCheckbox]:checked'); 
	 			if(selectedCards.length == 0){
	 				parent.$.jBox.tip('请勾选要导出长编','warning');
	 				return;
				}
	 			
	 			selectedCards.each(function(){
	 				//判断导出长编是否有未审核的
	  				if($(this).attr('status')=='finish')
	  					ids+=$(this).val()+",";
	  				else{
	  					//top.$.jBox.tip('只能导出已审核长编，请重新选择.','warning');
	  					alert('只当前选择长编中存在未审核长编，请重新选择.');
	  					$('[name=summaryCheckbox]').attr('checked',false);
	  					$("[name=checkAll]").attr('checked',false);
	  					ids='';
						return false;
	  				}
	 			});
		  		if(ids!=''){
		  			ids=ids.substr(0,ids.length-1);
		  			parent.$.jBox.tip('努力导出中,请耐心等待...','warning');
		  			$(this).attr('href', "${ctx}/summary/exportSummarys/"+ids+"?ticket=1_1&lv=4&objFilter=nobj,catalog&resourceType=${param.resourceType}");
		  		}
		  	});
		  	
			$('#exportAll').click(function(){
				
				if(!confirm("是否导出长编全文,请确认?"))
					return;
				
				var nodes=parent.zTreeobj.getNodes();

				var ids='';
				$.each(nodes,function(i,n){
					ids+=n.nid+",";
				});
				ids=ids.substring(0,ids.length-1);
				$.jBox.tip('努力下载中,请耐心等待...','warning');
				$(this).attr('href', "${ctx}/summary/exportAll?ids="+ids+"&ticket=1_1&lv=4&objFilter=nobj,catalog&resourceType=${param.resourceType}");
			});
		});
		
		function createSummary(){
			$("#gridForm").submit();
		}
		
		function forceRefresh(){
			refreshFlag = true;
		}
		
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		function doDel(id){
			parent.$.jBox.confirm("确定要删除吗？", "删除确认", function(v, h, f){
				if(v == 'ok'){
					$.ajax({
					    url : "${ctx}/summary/doDel/"+id,
						type : 'delete',
						success: function(data, status, xhr) {
							alert("删除成功！");
							$("#searchForm").submit();
				        }, 
				        error: function() {
				        	alert("对不起！你的请求出现异常，请联系服务人员！");
						}
					});						
				}
				return true;
			});			
		}	
		
		
		
	</script>
	<style>
	.form-search .ul-form li label {
		width: 110px;
	}
	.table th, .table td {text-align:center}
	.t_l{text-align:left}
	</style>
</head>
<body>
	<form id="searchForm" action="${ctx}/summary/list" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.currentPage}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input name="pId" type="hidden" value="${params.pId}"/>
		<input name="pType" type="hidden" value="${params.pType}"/>
		<input name="lv" type="hidden" value="${params.lv}"/>
		<input type="hidden" name="op" value="${params.op}" />
		<input type="hidden" name="resourceType" value="${params.resourceType}" />
		<ul class="ul-form">
			<li><label>资料代码：</label>
			<input type="text" name="code_l" maxlength="50" class="input-small" value="${params.code_l}"/>
			</li>
			<li><label>资料内容标题：</label>
			<input type="text" name="contentTitle_l" maxlength="50" class="input-small" value="${params.contentTitle_l}"/>
			</li>			
			<li><label>资料正文：</label>
			<input type="text" name="content_l" maxlength="50" class="input-small" value="${params.content_l}"/>
			</li>
			<li><label>资料整理者：</label>
			<input type="text" name="operateUser_l" maxlength="50" class="input-small" value="${params.operateUser_l}"/>
			</li>			
			<li><label>资料内容时间：</label>
			<input type="text" class="input-small" name="contentTimeEnd_s" value="${params.contentTimeEnd_s}" readonly onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
			~<input type="text" class="input-small" name="contentTimeStart_e" value="${params.contentTimeStart_e}" readonly onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
			</li>		
			<li><label>资料整理时间：</label>
			<input type="text" class="input-small" name="operateTime_s" value="${params.operateTime_s}" readonly onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
			~<input type="text" class="input-small" name="operateTime_e" value="${params.operateTime_e}" readonly onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
			</li>					
			<li><label>资料报送单位：</label>
			<input type="text" name="operateDept_l" maxlength="50" class="input-small" value="${params.operateDept_l}"/>
			</li>									
			<li><label>审核状态：</label>
		      <select name="status" class="input-medium-select creset">
		        <c:forEach items="${fields.status.option}" var="op">
		          <option value="${op.key}" ${op.key==params.status ? 'selected':''}>${op.value}</option>
		        </c:forEach>
		      </select>			
			</li>						
			<li class="clearfix"></li>
		</ul>
		<div class="input01"><a id="btnSubmit" href="javascript:void(0)">查询</a><a id="resetBut" href="javascript:void(0)">重置</a></div>		
	</form>
	<div class="wd-butbar">
	     <div class="top-a">
<%-- 	     ${ctx}/summary/exportSummarys/33,35,38?ticket=1_1&lv=4&objFilter=nobj,catalog&resourceType=dsj --%>
	      <a class="a05" id='export' title="长编导出" ></a>
	      <a class="a08" id='exportAll'  title="全文导出"></a> 
	     </div>	
	</div>	
	<form id="gridForm" action="${ctx}/summary/create" method="post" target="_blank">
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr><th width="30px"><input name="checkAll" type="checkbox" value="">序号</th>
				<th width="10%">资料代码</th>
				<th>资料内容开始时间</th>
				<th>资料内容结束时间</th>
				<th>资料内容标题</th>
				<th>报送单位</th>
				<th>资料整理者</th>
				<th>资料整理时间</th>
				<th>审核状态</th>
				<th>编撰状态</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${list}" var="summary"  varStatus="rownum" >
			<tr>
				<td style="text-align: center;"><input name="summaryCheckbox" type="checkbox" value="${summary.id}" status="${summary.status}">${rownum.count}</td>
				<td class="t_l">
					${summary.code}
				</td>
				<td>
					${summary.contentTimeStart}
				</td>
				<td>
					${summary.contentTimeEnd}
				</td>
				<td>
					${summary.contentTitle}
				</td>
				<td>
					${summary.operateDept}
				</td>				
				<td>
					${summary.operateUser}
				</td>				
				<td>
					${summary.operateTime}
				</td>								
				<td>
					${fields.status.option[summary.status]}
				</td>	
				<td>
				
				    
					<c:if test="${summary.complieStatus == 'finish'   }">
						${fields.complieStatus.option[summary.complieStatus]}
					</c:if>
					<c:if test="${((summary.status == 'draft' || summary.complieStatus == 'modify' ) ) 
									&& params.op!='0'}">
									
					    <c:if test="${( sessionScope.userId == summary.operateUserId) }">
						<a href="${ctx}/summary/compliedit?id=${summary.id}&resourceType=${param.resourceType}" target="_blank" onclick="forceRefresh()">
						${fields.complieStatus.option[summary.complieStatus]}
						</a>
					     </c:if>
					     <c:if test="${( sessionScope.userId != summary.operateUserId) }">
					        ${fields.complieStatus.option[summary.complieStatus]}
					     </c:if>
									
						      
						</a>					
					</c:if>
					
					<c:if test="${((summary.complieStatus == 'inition' )  ) 
									&& params.op!='0'}">
						${fields.complieStatus.option[summary.complieStatus]} 
						
					</c:if>
 					<c:if test="${((summary.complieStatus == 'start' ) ) 
									&& params.op!='0'}">
									
					<c:if test="${(fn:indexOf(flowUsers[summary.processInstanceId] ,sessionScope.loginName)=='-1' ) }">
						${fields.complieStatus.option[summary.complieStatus]} 
						
					</c:if>
					<c:if test="${(fn:indexOf(flowUsers[summary.processInstanceId] ,sessionScope.loginName)!='-1' ) }">
					
						<a href="${ctx}/summary/compliedit?id=${summary.id}&resourceType=${param.resourceType}" target="_blank" onclick="forceRefresh()">
												${fields.complieStatus.option[summary.complieStatus]}
						</a>
						</c:if>
					</c:if>
					
				</td>	
				<td>
					<a href="${ctx}/summary/view?id=${summary.id}" target="_blank">查看</a>
					<%-- <c:if test="${((summary.status == 'draft' && (sessionScope.isChron || sessionScope.deptId==summary.operateDeptId)) || (summary.status == 'modify' && sessionScope.userId == summary.operateUserId)) --%>
					<c:if test="${((summary.status == 'draft' || summary.status == 'modify') && sessionScope.userId == summary.operateUserId) 
									&& params.op!='0'}">
						<a href="${ctx}/summary/edit?id=${summary.id}&resourceType=${param.resourceType}" target="_blank" onclick="forceRefresh()">修改</a>
					</c:if>
					<c:if test="${summary.status == 'draft' && (sessionScope.isChron || sessionScope.deptId==summary.operateDeptId) && params.op!='0'}">
						<a href="javascript:doDel('${summary.id}');">删除</a>
					</c:if>					
				</td>						
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</form>
	<div class="pagination">${pagination}</div>
</body>
</html>